package base;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Developer on 23.06.13.
 */
public class Base {
    public static Date parseDate(String dateStr){
        SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
        Date date = null;
        try {
            date = (Date) format.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
            Lg.err(e);
        }
        return date;
    }

    public static String makeDate(int day,int month,int year){
//        String format = sp.getString(DATE_FORMAT, "dd-MM-yyyy");
        String format = "dd.MM.yyyy";
        if(format.equals("dd-MM-yyyy"))
            return (day<10?"0"+day:day) + "-" + ((month+1)<10?"0"+(month+1):(month+1)) + "-" + year;
        else if(format.equals("dd.MM.yyyy"))
            return (day<10?"0"+day:day) + "." + ((month+1)<10?"0"+(month+1):(month+1)) + "." + year;
        else if(format.equals("MM-dd-yyyy"))
            return (month+1)<10?"0"+(month+1):(month+1) + "-" + (day<10?"0"+day:day) + "-" + year;
        else if(format.equals("MM.dd.yyyy"))
            return (month+1)<10?"0"+(month+1):(month+1) + "." + (day<10?"0"+day:day) + "." + year;
        else
            return (year + "-" + ((month+1)<10?"0"+(month+1):(month+1)) + "-" + (day<10?"0"+day:day));
    }
}
